/*
 * Copyright 2016 Yan Zhenjie
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.mingmen.supplier.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.google.gson.Gson;
import com.mingmen.supplier.R;
import com.mingmen.supplier.adapter.LoginRestruantAdapter;
import com.mingmen.supplier.defineview.ClearEditText;
import com.mingmen.supplier.model.LoginBean;
import com.mingmen.supplier.model.LoginShenHeModel;
import com.mingmen.supplier.util.GsonUtil;
import com.mingmen.supplier.util.PinnedHeaderDecoration;
import com.mingmen.supplier.util.SharePreferenceUtil;
import com.mingmen.supplier.util.Trans2PinYinUtil;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import de.greenrobot.event.EventBus;


/**
 * <p>
 * ListView形式的侧滑菜单，支持横向和竖向的。
 * </p>
 * Created by Yan Zhenjie on 2016/7/27.
 */
public class LoginShenHeActivity extends Activity {


    String attrs = "";
    @BindView(R.id.img_shenhezhong)
    ImageView img_shenhezhong;
    @BindView(R.id.text_status)
    TextView text_status;
    @BindView(R.id.text_reason)
    TextView text_reason;
    @BindView(R.id.text_redReason)
    TextView text_redReason;
    @BindView(R.id.btn_login)
    Button btn_login;
    @BindView(R.id.btn_know)
    Button btn_know;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_newfitter_lis);

        ButterKnife.bind(this);

        attrs = getIntent().getStringExtra("logindata");
        LoginShenHeModel loginShenHeModel = new LoginShenHeModel();
        loginShenHeModel = GsonUtil.GsonToBean(attrs, LoginShenHeModel.class);
        if (loginShenHeModel.getCode() == 501) {
            img_shenhezhong.setImageResource(R.mipmap.shenhezhong);
            text_status.setText("已提交，系统审核中");
            text_reason.setText("结果将以短信形式发送给您，请您耐心等待...");
            text_redReason.setVisibility(View.GONE);
            btn_login.setVisibility(View.INVISIBLE);
            btn_know.setBackground(getResources().getDrawable(R.drawable.btnlogin_selector));
            btn_know.setTextColor(getResources().getColor(R.color.white));
        } else if (loginShenHeModel.getCode() == 502) {
            img_shenhezhong.setImageResource(R.mipmap.shenhefail);
            text_redReason.setText("失败原因:" + loginShenHeModel.getData());
        }


    }


    @Override
    protected void onDestroy() {
        super.onDestroy();

    }

    @OnClick({R.id.btn_know, R.id.btn_login})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btn_know:

                finish();
                break;
            case R.id.btn_login:
                startActivity(new Intent(LoginShenHeActivity.this, RegisterActivity.class));
                break;
        }
    }

}